#pragma once
#ifndef SCRIPT_ENGINE_COMMON_DEFINITIONS_H
#define SCRIPT_ENGINE_COMMON_DEFINITIONS_H

typedef struct SYMBOL
{
    long long unsigned Type;
    long long unsigned Len;
    long long unsigned Value;
    
} SYMBOL, *PSYMBOL;

#define SIZE_SYMBOL_WITHOUT_LEN sizeof(long long unsigned) * 2

typedef struct HWDBG_SHORT_SYMBOL
{
    long long unsigned Type;
    long long unsigned Value;
    
} HWDBG_SHORT_SYMBOL, *PHWDBG_SHORT_SYMBOL;

typedef struct SYMBOL_BUFFER {
    PSYMBOL Head;
    unsigned int Pointer;
    unsigned int Size;
    char* Message;
} SYMBOL_BUFFER, * PSYMBOL_BUFFER;

typedef struct SYMBOL_MAP
{
    char* Name;
    long long unsigned Type;
} SYMBOL_MAP, * PSYMBOL_MAP;

typedef struct ACTION_BUFFER {
  long long unsigned Tag;
  long long unsigned CurrentAction;
  char ImmediatelySendTheResults;
  long long unsigned Context;
  char CallingStage;
} ACTION_BUFFER, *PACTION_BUFFER;

#define SYMBOL_UNDEFINED 0
#define SYMBOL_GLOBAL_ID_TYPE 1
#define SYMBOL_LOCAL_ID_TYPE 2
#define SYMBOL_NUM_TYPE 3
#define SYMBOL_REGISTER_TYPE 4
#define SYMBOL_PSEUDO_REG_TYPE 5
#define SYMBOL_SEMANTIC_RULE_TYPE 6
#define SYMBOL_TEMP_TYPE 7
#define SYMBOL_STRING_TYPE 8
#define SYMBOL_VARIABLE_COUNT_TYPE 9
#define SYMBOL_INVALID 10
#define SYMBOL_WSTRING_TYPE 11
#define SYMBOL_FUNCTION_PARAMETER_ID_TYPE 12
#define SYMBOL_RETURN_ADDRESS_TYPE 13
#define SYMBOL_FUNCTION_PARAMETER_TYPE 14
#define SYMBOL_STACK_INDEX_TYPE 15
#define SYMBOL_STACK_BASE_INDEX_TYPE 16
#define SYMBOL_RETURN_VALUE_TYPE 17
#define SYMBOL_REFERENCE_LOCAL_ID_TYPE 18
#define SYMBOL_REFERENCE_TEMP_TYPE 19
#define SYMBOL_DEREFERENCE_LOCAL_ID_TYPE 20
#define SYMBOL_DEREFERENCE_TEMP_TYPE 21

static const char *const SymbolTypeNames[] = {
"SYMBOL_UNDEFINED",
"SYMBOL_GLOBAL_ID_TYPE",
"SYMBOL_LOCAL_ID_TYPE",
"SYMBOL_NUM_TYPE",
"SYMBOL_REGISTER_TYPE",
"SYMBOL_PSEUDO_REG_TYPE",
"SYMBOL_SEMANTIC_RULE_TYPE",
"SYMBOL_TEMP_TYPE",
"SYMBOL_STRING_TYPE",
"SYMBOL_VARIABLE_COUNT_TYPE",
"SYMBOL_INVALID",
"SYMBOL_WSTRING_TYPE",
"SYMBOL_FUNCTION_PARAMETER_ID_TYPE",
"SYMBOL_RETURN_ADDRESS_TYPE",
"SYMBOL_FUNCTION_PARAMETER_TYPE",
"SYMBOL_STACK_INDEX_TYPE",
"SYMBOL_STACK_BASE_INDEX_TYPE",
"SYMBOL_RETURN_VALUE_TYPE",
"SYMBOL_REFERENCE_LOCAL_ID_TYPE",
"SYMBOL_REFERENCE_TEMP_TYPE",
"SYMBOL_DEREFERENCE_LOCAL_ID_TYPE",
"SYMBOL_DEREFERENCE_TEMP_TYPE"
};

#define SYMBOL_MEM_VALID_CHECK_MASK (1 << 31)
#define INVALID 0x80000000
#define LALR_ACCEPT 0x7fffffff



#define FUNC_UNDEFINED 0
#define FUNC_INC 1
#define FUNC_DEC 2
#define FUNC_REFERENCE 3
#define FUNC_OR 4
#define FUNC_XOR 5
#define FUNC_AND 6
#define FUNC_ASR 7
#define FUNC_ASL 8
#define FUNC_ADD 9
#define FUNC_SUB 10
#define FUNC_MUL 11
#define FUNC_DIV 12
#define FUNC_MOD 13
#define FUNC_GT 14
#define FUNC_LT 15
#define FUNC_EGT 16
#define FUNC_ELT 17
#define FUNC_EQUAL 18
#define FUNC_NEQ 19
#define FUNC_JMP 20
#define FUNC_JZ 21
#define FUNC_JNZ 22
#define FUNC_MOV 23
#define FUNC_START_OF_DO_WHILE 24
#define FUNC_START_OF_DO_WHILE_COMMANDS 25
#define FUNC_END_OF_DO_WHILE 26
#define FUNC_START_OF_FOR 27
#define FUNC_FOR_INC_DEC 28
#define FUNC_START_OF_FOR_OMMANDS 29
#define FUNC_END_OF_IF 30
#define FUNC_IGNORE_LVALUE 31
#define FUNC_PUSH 32
#define FUNC_POP 33
#define FUNC_CALL 34
#define FUNC_RET 35
#define FUNC_PRINT 36
#define FUNC_FORMATS 37
#define FUNC_EVENT_ENABLE 38
#define FUNC_EVENT_DISABLE 39
#define FUNC_EVENT_CLEAR 40
#define FUNC_TEST_STATEMENT 41
#define FUNC_SPINLOCK_LOCK 42
#define FUNC_SPINLOCK_UNLOCK 43
#define FUNC_EVENT_SC 44
#define FUNC_MICROSLEEP 45
#define FUNC_PRINTF 46
#define FUNC_PAUSE 47
#define FUNC_FLUSH 48
#define FUNC_EVENT_TRACE_STEP 49
#define FUNC_EVENT_TRACE_STEP_IN 50
#define FUNC_EVENT_TRACE_STEP_OUT 51
#define FUNC_EVENT_TRACE_INSTRUMENTATION_STEP 52
#define FUNC_EVENT_TRACE_INSTRUMENTATION_STEP_IN 53
#define FUNC_RDTSC 54
#define FUNC_RDTSCP 55
#define FUNC_SPINLOCK_LOCK_CUSTOM_WAIT 56
#define FUNC_EVENT_INJECT 57
#define FUNC_POI 58
#define FUNC_DB 59
#define FUNC_DD 60
#define FUNC_DW 61
#define FUNC_DQ 62
#define FUNC_NEG 63
#define FUNC_HI 64
#define FUNC_LOW 65
#define FUNC_NOT 66
#define FUNC_CHECK_ADDRESS 67
#define FUNC_DISASSEMBLE_LEN 68
#define FUNC_DISASSEMBLE_LEN32 69
#define FUNC_DISASSEMBLE_LEN64 70
#define FUNC_INTERLOCKED_INCREMENT 71
#define FUNC_INTERLOCKED_DECREMENT 72
#define FUNC_PHYSICAL_TO_VIRTUAL 73
#define FUNC_VIRTUAL_TO_PHYSICAL 74
#define FUNC_POI_PA 75
#define FUNC_HI_PA 76
#define FUNC_LOW_PA 77
#define FUNC_DB_PA 78
#define FUNC_DD_PA 79
#define FUNC_DW_PA 80
#define FUNC_DQ_PA 81
#define FUNC_ED 82
#define FUNC_EB 83
#define FUNC_EQ 84
#define FUNC_INTERLOCKED_EXCHANGE 85
#define FUNC_INTERLOCKED_EXCHANGE_ADD 86
#define FUNC_EB_PA 87
#define FUNC_ED_PA 88
#define FUNC_EQ_PA 89
#define FUNC_INTERLOCKED_COMPARE_EXCHANGE 90
#define FUNC_STRLEN 91
#define FUNC_STRCMP 92
#define FUNC_MEMCMP 93
#define FUNC_STRNCMP 94
#define FUNC_WCSLEN 95
#define FUNC_WCSCMP 96
#define FUNC_EVENT_INJECT_ERROR_CODE 97
#define FUNC_MEMCPY 98
#define FUNC_MEMCPY_PA 99
#define FUNC_WCSNCMP 100

static const char *const FunctionNames[] = {
"FUNC_UNDEFINED",
"FUNC_INC",
"FUNC_DEC",
"FUNC_REFERENCE",
"FUNC_OR",
"FUNC_XOR",
"FUNC_AND",
"FUNC_ASR",
"FUNC_ASL",
"FUNC_ADD",
"FUNC_SUB",
"FUNC_MUL",
"FUNC_DIV",
"FUNC_MOD",
"FUNC_GT",
"FUNC_LT",
"FUNC_EGT",
"FUNC_ELT",
"FUNC_EQUAL",
"FUNC_NEQ",
"FUNC_JMP",
"FUNC_JZ",
"FUNC_JNZ",
"FUNC_MOV",
"FUNC_START_OF_DO_WHILE",
"FUNC_START_OF_DO_WHILE_COMMANDS",
"FUNC_END_OF_DO_WHILE",
"FUNC_START_OF_FOR",
"FUNC_FOR_INC_DEC",
"FUNC_START_OF_FOR_OMMANDS",
"FUNC_END_OF_IF",
"FUNC_IGNORE_LVALUE",
"FUNC_PUSH",
"FUNC_POP",
"FUNC_CALL",
"FUNC_RET",
"FUNC_PRINT",
"FUNC_FORMATS",
"FUNC_EVENT_ENABLE",
"FUNC_EVENT_DISABLE",
"FUNC_EVENT_CLEAR",
"FUNC_TEST_STATEMENT",
"FUNC_SPINLOCK_LOCK",
"FUNC_SPINLOCK_UNLOCK",
"FUNC_EVENT_SC",
"FUNC_MICROSLEEP",
"FUNC_PRINTF",
"FUNC_PAUSE",
"FUNC_FLUSH",
"FUNC_EVENT_TRACE_STEP",
"FUNC_EVENT_TRACE_STEP_IN",
"FUNC_EVENT_TRACE_STEP_OUT",
"FUNC_EVENT_TRACE_INSTRUMENTATION_STEP",
"FUNC_EVENT_TRACE_INSTRUMENTATION_STEP_IN",
"FUNC_RDTSC",
"FUNC_RDTSCP",
"FUNC_SPINLOCK_LOCK_CUSTOM_WAIT",
"FUNC_EVENT_INJECT",
"FUNC_POI",
"FUNC_DB",
"FUNC_DD",
"FUNC_DW",
"FUNC_DQ",
"FUNC_NEG",
"FUNC_HI",
"FUNC_LOW",
"FUNC_NOT",
"FUNC_CHECK_ADDRESS",
"FUNC_DISASSEMBLE_LEN",
"FUNC_DISASSEMBLE_LEN32",
"FUNC_DISASSEMBLE_LEN64",
"FUNC_INTERLOCKED_INCREMENT",
"FUNC_INTERLOCKED_DECREMENT",
"FUNC_PHYSICAL_TO_VIRTUAL",
"FUNC_VIRTUAL_TO_PHYSICAL",
"FUNC_POI_PA",
"FUNC_HI_PA",
"FUNC_LOW_PA",
"FUNC_DB_PA",
"FUNC_DD_PA",
"FUNC_DW_PA",
"FUNC_DQ_PA",
"FUNC_ED",
"FUNC_EB",
"FUNC_EQ",
"FUNC_INTERLOCKED_EXCHANGE",
"FUNC_INTERLOCKED_EXCHANGE_ADD",
"FUNC_EB_PA",
"FUNC_ED_PA",
"FUNC_EQ_PA",
"FUNC_INTERLOCKED_COMPARE_EXCHANGE",
"FUNC_STRLEN",
"FUNC_STRCMP",
"FUNC_MEMCMP",
"FUNC_STRNCMP",
"FUNC_WCSLEN",
"FUNC_WCSCMP",
"FUNC_EVENT_INJECT_ERROR_CODE",
"FUNC_MEMCPY",
"FUNC_MEMCPY_PA",
"FUNC_WCSNCMP",
};

typedef enum REGS_ENUM {
	REGISTER_RAX = 0,
	REGISTER_EAX = 1,
	REGISTER_AX = 2,
	REGISTER_AH = 3,
	REGISTER_AL = 4,
	REGISTER_RCX = 5,
	REGISTER_ECX = 6,
	REGISTER_CX = 7,
	REGISTER_CH = 8,
	REGISTER_CL = 9,
	REGISTER_RDX = 10,
	REGISTER_EDX = 11,
	REGISTER_DX = 12,
	REGISTER_DH = 13,
	REGISTER_DL = 14,
	REGISTER_RBX = 15,
	REGISTER_EBX = 16,
	REGISTER_BX = 17,
	REGISTER_BH = 18,
	REGISTER_BL = 19,
	REGISTER_RSP = 20,
	REGISTER_ESP = 21,
	REGISTER_SP = 22,
	REGISTER_SPL = 23,
	REGISTER_RBP = 24,
	REGISTER_EBP = 25,
	REGISTER_BP = 26,
	REGISTER_BPL = 27,
	REGISTER_RSI = 28,
	REGISTER_ESI = 29,
	REGISTER_SI = 30,
	REGISTER_SIL = 31,
	REGISTER_RDI = 32,
	REGISTER_EDI = 33,
	REGISTER_DI = 34,
	REGISTER_DIL = 35,
	REGISTER_R8 = 36,
	REGISTER_R8D = 37,
	REGISTER_R8W = 38,
	REGISTER_R8H = 39,
	REGISTER_R8L = 40,
	REGISTER_R9 = 41,
	REGISTER_R9D = 42,
	REGISTER_R9W = 43,
	REGISTER_R9H = 44,
	REGISTER_R9L = 45,
	REGISTER_R10 = 46,
	REGISTER_R10D = 47,
	REGISTER_R10W = 48,
	REGISTER_R10H = 49,
	REGISTER_R10L = 50,
	REGISTER_R11 = 51,
	REGISTER_R11D = 52,
	REGISTER_R11W = 53,
	REGISTER_R11H = 54,
	REGISTER_R11L = 55,
	REGISTER_R12 = 56,
	REGISTER_R12D = 57,
	REGISTER_R12W = 58,
	REGISTER_R12H = 59,
	REGISTER_R12L = 60,
	REGISTER_R13 = 61,
	REGISTER_R13D = 62,
	REGISTER_R13W = 63,
	REGISTER_R13H = 64,
	REGISTER_R13L = 65,
	REGISTER_R14 = 66,
	REGISTER_R14D = 67,
	REGISTER_R14W = 68,
	REGISTER_R14H = 69,
	REGISTER_R14L = 70,
	REGISTER_R15 = 71,
	REGISTER_R15D = 72,
	REGISTER_R15W = 73,
	REGISTER_R15H = 74,
	REGISTER_R15L = 75,
	REGISTER_DS = 76,
	REGISTER_ES = 77,
	REGISTER_FS = 78,
	REGISTER_GS = 79,
	REGISTER_CS = 80,
	REGISTER_SS = 81,
	REGISTER_RFLAGS = 82,
	REGISTER_EFLAGS = 83,
	REGISTER_FLAGS = 84,
	REGISTER_CF = 85,
	REGISTER_PF = 86,
	REGISTER_AF = 87,
	REGISTER_ZF = 88,
	REGISTER_SF = 89,
	REGISTER_TF = 90,
	REGISTER_IF = 91,
	REGISTER_DF = 92,
	REGISTER_OF = 93,
	REGISTER_IOPL = 94,
	REGISTER_NT = 95,
	REGISTER_RF = 96,
	REGISTER_VM = 97,
	REGISTER_AC = 98,
	REGISTER_VIF = 99,
	REGISTER_VIP = 100,
	REGISTER_ID = 101,
	REGISTER_RIP = 102,
	REGISTER_EIP = 103,
	REGISTER_IP = 104,
	REGISTER_IDTR = 105,
	REGISTER_LDTR = 106,
	REGISTER_GDTR = 107,
	REGISTER_TR = 108,
	REGISTER_CR0 = 109,
	REGISTER_CR2 = 110,
	REGISTER_CR3 = 111,
	REGISTER_CR4 = 112,
	REGISTER_CR8 = 113,
	REGISTER_DR0 = 114,
	REGISTER_DR1 = 115,
	REGISTER_DR2 = 116,
	REGISTER_DR3 = 117,
	REGISTER_DR6 = 118,
	REGISTER_DR7 = 119

} REGS_ENUM;

static const char *const RegistersNames[] = {
"rax", "eax", "ax", "ah", "al", "rcx", "ecx", "cx",
"ch", "cl", "rdx", "edx", "dx", "dh", "dl", "rbx",
"ebx", "bx", "bh", "bl", "rsp", "esp", "sp", "spl",
"rbp", "ebp", "bp", "bpl", "rsi", "esi", "si", "sil",
"rdi", "edi", "di", "dil", "r8", "r8d", "r8w", "r8h",
"r8l", "r9", "r9d", "r9w", "r9h", "r9l", "r10", "r10d",
"r10w", "r10h", "r10l", "r11", "r11d", "r11w", "r11h", "r11l",
"r12", "r12d", "r12w", "r12h", "r12l", "r13", "r13d", "r13w",
"r13h", "r13l", "r14", "r14d", "r14w", "r14h", "r14l", "r15",
"r15d", "r15w", "r15h", "r15l", "ds", "es", "fs", "gs",
"cs", "ss", "rflags", "eflags", "flags", "cf", "pf", "af",
"zf", "sf", "tf", "if", "df", "of", "iopl", "nt",
"rf", "vm", "ac", "vif", "vip", "id", "rip", "eip",
"ip", "idtr", "ldtr", "gdtr", "tr", "cr0", "cr2", "cr3",
"cr4", "cr8", "dr0", "dr1", "dr2", "dr3", "dr6", 	"dr7"
};

#define PSEUDO_REGISTER_PID 0
#define PSEUDO_REGISTER_TID 1
#define PSEUDO_REGISTER_PNAME 2
#define PSEUDO_REGISTER_CORE 3
#define PSEUDO_REGISTER_PROC 4
#define PSEUDO_REGISTER_THREAD 5
#define PSEUDO_REGISTER_PEB 6
#define PSEUDO_REGISTER_TEB 7
#define PSEUDO_REGISTER_IP 8
#define PSEUDO_REGISTER_BUFFER 9
#define PSEUDO_REGISTER_CONTEXT 10
#define PSEUDO_REGISTER_EVENT_TAG 11
#define PSEUDO_REGISTER_EVENT_ID 12
#define PSEUDO_REGISTER_EVENT_STAGE 13
#define PSEUDO_REGISTER_DATE 14
#define PSEUDO_REGISTER_TIME 15

#endif
